<?php
/*
 * 桥接模式
 * 举例：公路把汽车和速度桥接起来
 */
abstract class car{
    abstract function getName();
}
class QQCar extends car{
    private $name;
    public function __construct(string $name)
    {
        $this->name = $name;
    }
    public function getName(){
        echo $this->name.PHP_EOL;
    }
}
class JLCar extends car{
    private $name;
    public function __construct(string $name)
    {
        $this->name = $name;
    }
    public function getName(){
        echo $this->name.PHP_EOL;
    }
}
abstract class sudu{
    abstract function showSudu();
}
class KuaiSu extends sudu{
    private $sudo;
    public function __construct(int $sudo)
    {
        $this->sudo = $sudo;
    }
    function showSudu()
    {
        echo "以每小时".$this->sudo."行驶".PHP_EOL;
    }
}
class road{
    private $car;
    private $sudu;
    public function __construct(car $car,sudu $sudu)
    {
        $this->car = $car;
        $this->sudu = $sudu;
    }
    public function run(){
        $this->car->getName();
        echo "在告诉公路".PHP_EOL;
        $this->sudu->showSudu();
    }
}
$obj = new road(new QQCar("我的QQ"),new KuaiSu(110));
$obj->run();